In [1]:
import numpy as np
import matplotlib.pyplot as plt
In [2]:
import plotly.graph_objects as go


# Helix equation
t = np.linspace(0, 20, 100)
x, y, z = np.cos(t), np.sin(t), t

fig = go.Figure(data=[go.Scatter3d(
    x=x,
    y=y,
    z=z,
    mode='markers',
    marker=dict(
        size=12,
        color=z,                # set color to an array/list of desired values
        colorscale='Viridis',   # choose a colorscale
        opacity=0.8
    )
)])

# tight layout
fig.update_layout(margin=dict(l=0, r=0, b=0, t=0))
fig.write_html("test.html") #Modifiy the html file
fig.show()
In [34]:
pwd
Out[34]:
'/home/macbuse/Documents/macbuse.github.io/MAT305'
In [10]:
import plotly.graph_objects as go

  
x = np.outer(np.linspace(-2, 2, 30), np.ones(30))
y = x.copy().T

z = np.sqrt(x ** 2 + y ** 2)
  
fig = go.Figure(data=[go.Surface(x=x, y=y, z=z)])
fig.update_layout(
    margin=dict(l=10, r=10, t=10, b=10),
    paper_bgcolor="LightSteelBlue",
)
fig.show()

fig.write_html("cone.html") #Modifiy the html file
In [7]:
dir(fig)
Out[7]:
['__class__',
 '__contains__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getitem__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__iter__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__setitem__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_add_annotation_like',
 '_allow_disable_validation',
 '_animation_duration_validator',
 '_animation_easing_validator',
 '_batch_layout_edits',
 '_batch_trace_edits',
 '_bracket_re',
 '_build_dispatch_plan',
 '_build_update_params_from_batch',
 '_config',
 '_data',
 '_data_defaults',
 '_data_objs',
 '_data_validator',
 '_dispatch_layout_change_callbacks',
 '_dispatch_trace_change_callbacks',
 '_filter_by_selector',
 '_frame_objs',
 '_frames_validator',
 '_get_child_prop_defaults',
 '_get_child_props',
 '_get_subplot_coordinates',
 '_get_subplot_rows_columns',
 '_grid_ref',
 '_grid_str',
 '_has_subplots',
 '_in_batch_mode',
 '_index_is',
 '_init_child_props',
 '_initialize_layout_template',
 '_ipython_display_',
 '_is_dict_list',
 '_is_key_path_compatible',
 '_layout',
 '_layout_defaults',
 '_layout_obj',
 '_layout_validator',
 '_make_axis_spanning_layout_object',
 '_normalize_trace_indexes',
 '_perform_batch_animate',
 '_perform_plotly_relayout',
 '_perform_plotly_restyle',
 '_perform_plotly_update',
 '_perform_select_traces',
 '_perform_update',
 '_process_multiple_axis_spanning_shapes',
 '_raise_invalid_rows_cols',
 '_relayout_child',
 '_repr_html_',
 '_repr_mimebundle_',
 '_restyle_child',
 '_select_annotations_like',
 '_select_layout_subplots_by_prefix',
 '_select_subplot_coordinates',
 '_selector_matches',
 '_send_addTraces_msg',
 '_send_animate_msg',
 '_send_deleteTraces_msg',
 '_send_moveTraces_msg',
 '_send_relayout_msg',
 '_send_restyle_msg',
 '_send_update_msg',
 '_set_in',
 '_set_trace_grid_position',
 '_set_trace_uid',
 '_str_to_dict_path',
 '_subplot_not_empty',
 '_to_ordered_dict',
 '_valid_underscore_properties',
 '_validate',
 '_validate_get_grid_ref',
 '_validate_rows_cols',
 'add_annotation',
 'add_bar',
 'add_barpolar',
 'add_box',
 'add_candlestick',
 'add_carpet',
 'add_choropleth',
 'add_choroplethmapbox',
 'add_cone',
 'add_contour',
 'add_contourcarpet',
 'add_densitymapbox',
 'add_funnel',
 'add_funnelarea',
 'add_heatmap',
 'add_heatmapgl',
 'add_histogram',
 'add_histogram2d',
 'add_histogram2dcontour',
 'add_hline',
 'add_hrect',
 'add_icicle',
 'add_image',
 'add_indicator',
 'add_isosurface',
 'add_layout_image',
 'add_mesh3d',
 'add_ohlc',
 'add_parcats',
 'add_parcoords',
 'add_pie',
 'add_pointcloud',
 'add_sankey',
 'add_scatter',
 'add_scatter3d',
 'add_scattercarpet',
 'add_scattergeo',
 'add_scattergl',
 'add_scattermapbox',
 'add_scatterpolar',
 'add_scatterpolargl',
 'add_scattersmith',
 'add_scatterternary',
 'add_shape',
 'add_splom',
 'add_streamtube',
 'add_sunburst',
 'add_surface',
 'add_table',
 'add_trace',
 'add_traces',
 'add_treemap',
 'add_violin',
 'add_vline',
 'add_volume',
 'add_vrect',
 'add_waterfall',
 'append_trace',
 'batch_animate',
 'batch_update',
 'data',
 'for_each_annotation',
 'for_each_coloraxis',
 'for_each_geo',
 'for_each_layout_image',
 'for_each_mapbox',
 'for_each_polar',
 'for_each_scene',
 'for_each_shape',
 'for_each_smith',
 'for_each_ternary',
 'for_each_trace',
 'for_each_xaxis',
 'for_each_yaxis',
 'frames',
 'full_figure_for_development',
 'get_subplot',
 'layout',
 'plotly_relayout',
 'plotly_restyle',
 'plotly_update',
 'pop',
 'print_grid',
 'select_annotations',
 'select_coloraxes',
 'select_geos',
 'select_layout_images',
 'select_mapboxes',
 'select_polars',
 'select_scenes',
 'select_shapes',
 'select_smiths',
 'select_ternaries',
 'select_traces',
 'select_xaxes',
 'select_yaxes',
 'set_subplots',
 'show',
 'to_dict',
 'to_html',
 'to_image',
 'to_json',
 'to_ordered_dict',
 'to_plotly_json',
 'update',
 'update_annotations',
 'update_coloraxes',
 'update_geos',
 'update_layout',
 'update_layout_images',
 'update_mapboxes',
 'update_polars',
 'update_scenes',
 'update_shapes',
 'update_smiths',
 'update_ternaries',
 'update_traces',
 'update_xaxes',
 'update_yaxes',
 'write_html',
 'write_image',
 'write_json']
In [4]:
x = np.outer(np.linspace(-4, 0, 30), np.ones(30))
y = np.outer(np.linspace(-5, 5, 30), np.ones(30)).T

fig = go.Figure(data=[go.Surface(x=x, y=y, z=(x + 2) ** 2 + 3)])
fig.
fig.show()


fig.write_html("half_pipe.html") #Modifiy the html file
In [48]:
x = np.outer(np.linspace(-2, 2, 30), np.ones(30))
y = np.outer(np.linspace(-2, 2, 30), np.ones(30)).T

  
fig = go.Figure(data=[go.Surface(x=x, y=y, z= -x+y)])
fig.show()

fig.write_html("plane_x.html") #Modifiy the html file
In [13]:
X = np.linspace(-2,2)
Y = -2*X + 3

plt.plot(X,Y,'r')
plt.plot(0*X,Y,'k')
plt.plot(X,0*Y + 3,'b')
plt.plot(X,0*Y,'k');
In [30]:
X1 = np.linspace(-4,0,100)
X = X1[ X1 + 2 > .1]

Y = 1 + 1/(X1 + 2)

plt.plot(X1,Y,'r')
    
    
Out[30]:
[<matplotlib.lines.Line2D at 0x7f1f2c8e0af0>]
In [32]:
x,y  = 5,10
f"{x} {y}"
Out[32]:
'5 10'
In [ ]: